using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace QFramework.Example
{
    public class BindablePropertyExample : MonoBehaviour
    {
        private BindableProperty<int> Age = new BindableProperty<int>(10);
        private BindableProperty<int> Counter = new BindableProperty<int>();

        // Start is called before the first frame update
        void Start()
        {
            Age.Register(age =>
            {
                Debug.Log(nameof(age) + ":" + age);

                Counter.Value = 10 * age;
            }).UnRegisterWhenGameObjectDestroyed(gameObject);

            Counter.RegisterWithInitValue(counter =>
            {
                Debug.Log(nameof(counter) + ":" + counter);
            }).UnRegisterWhenGameObjectDestroyed(gameObject);
        }

        // Update is called once per frame
        void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                Age.Value++;
            }
        }
    }
}

